VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Object = "{F0D2F211-CCB0-11D0-A316-00AA00688B10}#1.0#0"; "MSDATLST.OCX"
Begin VB.Form frmINV140 
   BackColor       =   &H8000000D&
   Caption         =   " INV140"
   ClientHeight    =   3900
   ClientLeft      =   2190
   ClientTop       =   1515
   ClientWidth     =   7320
   ControlBox      =   0   'False
   LinkTopic       =   "Form1"
   ScaleHeight     =   3900
   ScaleWidth      =   7320
   Begin MSAdodcLib.Adodc Adodc1 
      Height          =   375
      Left            =   5040
      Top             =   120
      Visible         =   0   'False
      Width           =   1455
      _ExtentX        =   2566
      _ExtentY        =   661
      ConnectMode     =   0
      CursorLocation  =   3
      IsolationLevel  =   -1
      ConnectionTimeout=   15
      CommandTimeout  =   30
      CursorType      =   3
      LockType        =   3
      CommandType     =   8
      CursorOptions   =   0
      CacheSize       =   50
      MaxRecords      =   0
      BOFAction       =   0
      EOFAction       =   0
      ConnectStringType=   1
      Appearance      =   1
      BackColor       =   -2147483643
      ForeColor       =   -2147483640
      Orientation     =   0
      Enabled         =   -1
      Connect         =   ""
      OLEDBString     =   ""
      OLEDBFile       =   ""
      DataSourceName  =   ""
      OtherAttributes =   ""
      UserName        =   ""
      Password        =   ""
      RecordSource    =   ""
      Caption         =   "Adodc1"
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      _Version        =   393216
   End
   Begin VB.Frame Frame1 
      BackColor       =   &H00E0E0E0&
      BorderStyle     =   0  'None
      Caption         =   "Frame1"
      Height          =   1608
      Left            =   336
      TabIndex        =   10
      Top             =   1392
      Width           =   6600
      Begin VB.TextBox txtCLDSC 
         Enabled         =   0   'False
         Height          =   720
         Left            =   2004
         Locked          =   -1  'True
         MultiLine       =   -1  'True
         TabIndex        =   14
         Top             =   516
         Width           =   4188
      End
      Begin VB.TextBox txtCLCLC 
         Enabled         =   0   'False
         Height          =   288
         Left            =   2025
         Locked          =   -1  'True
         TabIndex        =   13
         Top             =   72
         Width           =   1008
      End
      Begin VB.Label lbl 
         BackStyle       =   0  'Transparent
         Caption         =   "Item Class code"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H8000000D&
         Height          =   228
         Index           =   5
         Left            =   384
         TabIndex        =   12
         Top             =   144
         Width           =   1476
      End
      Begin VB.Label lbl 
         BackStyle       =   0  'Transparent
         Caption         =   "Description"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H8000000D&
         Height          =   228
         Index           =   3
         Left            =   744
         TabIndex        =   11
         Top             =   528
         Width           =   1092
      End
   End
   Begin VB.CommandButton cmdDelete 
      Caption         =   "&Delete"
      Height          =   372
      Left            =   4620
      TabIndex        =   7
      Top             =   3264
      Width           =   960
   End
   Begin VB.CommandButton cmdAddnew 
      Caption         =   "&New"
      Height          =   372
      Left            =   372
      TabIndex        =   4
      Top             =   3264
      Width           =   996
   End
   Begin VB.CommandButton cmdEdit 
      Caption         =   "&Edit"
      Height          =   372
      Left            =   1452
      TabIndex        =   3
      Top             =   3264
      Width           =   948
   End
   Begin VB.CommandButton cmdSave 
      Caption         =   "&Save"
      Height          =   372
      Left            =   2484
      TabIndex        =   2
      Top             =   3264
      Width           =   984
   End
   Begin VB.CommandButton cmdCancel 
      Caption         =   "&Cancel"
      Height          =   372
      Left            =   3528
      TabIndex        =   1
      Top             =   3264
      Width           =   1032
   End
   Begin VB.CommandButton cmdExit 
      Caption         =   "&Exit"
      Height          =   372
      Left            =   5640
      TabIndex        =   0
      Top             =   3264
      Width           =   1080
   End
   Begin MSDataListLib.DataCombo cboCLCLC 
      Bindings        =   "frmINV140.frx":0000
      Height          =   288
      Left            =   3396
      TabIndex        =   8
      Top             =   1008
      Width           =   2256
      _ExtentX        =   3995
      _ExtentY        =   556
      _Version        =   393216
      ListField       =   "CLDSC"
      BoundColumn     =   "CLCLC"
      Text            =   ""
   End
   Begin VB.Label lbl 
      BackStyle       =   0  'Transparent
      Caption         =   "Chose Item Class Review"
      BeginProperty Font 
         Name            =   "Verdana"
         Size            =   7.5
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H0080FFFF&
      Height          =   228
      Index           =   2
      Left            =   936
      TabIndex        =   9
      Top             =   1056
      Width           =   2376
   End
   Begin VB.Label lbl 
      BackStyle       =   0  'Transparent
      Caption         =   "INV140"
      BeginProperty Font 
         Name            =   "VNI-Present"
         Size            =   18
         Charset         =   0
         Weight          =   700
         Underline       =   -1  'True
         Italic          =   -1  'True
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00E0E0E0&
      Height          =   468
      Index           =   0
      Left            =   36
      TabIndex        =   6
      Top             =   24
      Width           =   1680
   End
   Begin VB.Label lbl 
      BackStyle       =   0  'Transparent
      Caption         =   "Item Class Mainternent"
      BeginProperty Font 
         Name            =   "Verdana"
         Size            =   16.5
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   -1  'True
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00E0E0E0&
      Height          =   492
      Index           =   1
      Left            =   1776
      TabIndex        =   5
      Top             =   420
      Width           =   4464
   End
End
Attribute VB_Name = "frmINV140"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim OldCLCLC As String
Private Sub WriteToFile(tri As Byte)
Dim SQLInsert As String
If tri = 0 Then
    SQLInsert = " INSERT INTO ICL " & _
                  "(CLCLC,CLDSC) " & _
                "VALUES " & _
                  "('" & txtCLCLC & "', '" & txtCLDSC & "')"
 Else
    SQLInsert = "UPDATE ICL SET CLCLC = '" & txtCLCLC & "', CLDSC ='" & txtCLDSC & "' " & _
                " WHERE CLCLC ='" & OldCLCLC & "'"
             
             
End If

Set cmdExecute = New ADODB.Command
Set cmdExecute.ActiveConnection = DBconn
cmdExecute.CommandText = SQLInsert
cmdExecute.Execute

End Sub

Private Sub WriteToScreen(tri As Byte)
If tri = 0 Then 'gan rong
   
        txtCLCLC = ""
        txtCLDSC = ""
        
       
Else
        Dim TBL As ADODB.Recordset
        Set TBL = New ADODB.Recordset
        TBL.Open "  Select ICL.*From ICL where  CLCLC ='" & cboCLCLC.BoundText & "'", DBconn, adOpenKeyset, adLockOptimistic, adCmdText
        If TBL.EOF = False Then
            txtCLCLC = IIf(IsNull(TBL!CLCLC), "", TBL!CLCLC)
            txtCLDSC = IIf(IsNull(TBL!CLdsc), "", TBL!CLdsc)
            
        Else
            cboCLCLC.BoundText = ""
            txtCLCLC = ""
            txtCLDSC = ""
            
        End If
        TBL.Close
End If
OldCLCLC = txtCLCLC
End Sub

Private Sub Control(GT As Variant)
    
    txtCLCLC.Enabled = GT
    txtCLDSC.Enabled = GT

    txtCLCLC.Locked = Not GT
    txtCLDSC.Locked = Not GT
    
    cboCLCLC.Enabled = Not GT
    cboCLCLC.Locked = GT
End Sub

Sub ButtonStatus()
cmdAddnew.Enabled = Not ISEDITING
cmdEdit.Enabled = Not ISEDITING
cmdSave.Enabled = ISEDITING ' And txtIMITN <> ""
cmdDelete.Enabled = Not ISEDITING 'And txtIMITN <> ""
cmdCancel.Enabled = ISEDITING
'txtIMITN.Locked = Not ISADDING ' Lock item code tru truong hop ISADDING=true
'txtDepartment.Enabled = ISEDITING
'cboDepartment.Visible = Not ISADDING
'txtDepartmentID.Visible = ISADDING
End Sub

Private Sub cboCLCLC_Click(Area As Integer)
If Area = 2 Then
    WriteToScreen (1)
End If

End Sub

Private Sub cmdAddnew_Click()
ISADDING = True
ISEDITING = True
WriteToScreen (0)
Control (True)
' Ham Gan tri man hinh
ButtonStatus


End Sub

Private Sub cmdCancel_Click()
' Gan tri man nhinh
ISADDING = False
ISEDITING = False
Control (False)
ButtonStatus
txtCLCLC = cboCLCLC.BoundText
WriteToScreen (1)

End Sub

Private Sub cmdDelete_Click()
Dim SQL As String
SQL = "DELETE FROM ICL WHERE CLCLC = '" & cboCLCLC.BoundText & "'"

Set cmdExecute = New ADODB.Command
Set cmdExecute.ActiveConnection = DBconn
cmdExecute.CommandText = SQL
cmdExecute.Execute
Adodc1.Refresh
WriteToScreen (0)

End Sub

Private Sub cmdEdit_Click()
ISEDITING = True
' Ham gan tri man hinh
ISADDING = False
ISEDITING = True
Control (True)

ButtonStatus


End Sub

Private Sub cmdExit_Click()
Unload frmINV140
End Sub

Private Sub cmdSave_Click()
' Ham Save tri vao file
'Dim tbl_ChapNhan As ADODB.Recordset
'Set tbl_ChapNhan = New ADODB.Recordset
'tbl_ChapNhan.Open "  Select IIM.*From IIM ", DBconn, adOpenKeyset, adLockOptimistic, adCmdText
'tbl_ChapNhan.Close
If ISADDING = False Then
    WriteToFile (1)
Else
    WriteToFile (0)
End If
Adodc1.Refresh
Control (False)
'''''''''''
ISADDING = False
ISEDITING = False

ButtonStatus

End Sub

Private Sub Form_Load()
BIENCHUNG
Adodc1.ConnectionString = ConnectString
Adodc1.ConnectionTimeout = 10
Adodc1.CommandType = adCmdTable
Adodc1.RecordSource = "ICL" 'Item CLASE
Adodc1.Refresh

ISADDING = False
ISEDITING = False
ButtonStatus

End Sub

Private Sub txtCLCLC_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
    If ValidMaso(OldCLCLC, txtCLCLC, "ICL", " CLCLC='" & txtCLCLC & "'") Then
        MsgBox "This code is already exist"
        txtCLCLC.SetFocus
    Else
        txtCLDSC.SetFocus
    End If
End If
End Sub
